package com.example.order.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.json.JSONUtil;
import com.example.order.common.R;
import com.example.order.pojo.Order;
import com.example.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description TODO
 * @Author JFeng
 * @Date 2024/4/19
 */

@RestController
@RequestMapping("/order")
@RefreshScope // 修改配置中心的配置后，会刷新配置
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/add/{totalAmount}")
    public Object add(@PathVariable BigDecimal totalAmount) {

        Map<Object, Object> map = new HashMap<>();
        R<Order> orderR = orderService.addOrder(totalAmount);
        map.put("RequestMapping", "/add生成订单");
        map.put("boolean", orderR);

        return JSONUtil.toJsonStr(map);
    }


}
